<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>管理后台</title>
    <meta name="keywords" content="index">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <meta name="apple-mobile-web-app-title" content="管理后台" />
    {include file="common:css" /}

</head>

<body data-type="login">

    <div class="am-g tpl-g">
        <!-- 风格切换 -->
      <!--  <div class="tpl-skiner">
            <div class="tpl-skiner-toggle am-icon-cog">
            </div>
            <div class="tpl-skiner-content">
                <div class="tpl-skiner-content-title">
                    选择主题
                </div>
                <div class="tpl-skiner-content-bar">
                    <span class="skiner-color skiner-black" data-color="theme-black"></span>
                    <span class="skiner-color skiner-white" data-color="theme-white"></span>
                </div>
            </div>
        </div>-->
        <div class="tpl-login">
            <div class="tpl-login-content">
                <div style="font-size: 30px;text-align: center;">
                    {eq name="ADMINTYPE" value="2"}加盟商{/eq}管理后台
                </div>
                <form class="am-form tpl-form-line-form">
                    <div class="am-form-group">
                        <input type="text" name="username" class="tpl-form-input" id="user-name" placeholder=" {eq name="ADMINTYPE" value="2"}请输入电话号码登录{else}请输入账号{/eq}">
                    </div>
                    <div class="am-form-group">
                        <input type="password"  name="password" class="tpl-form-input" id="user-password" placeholder="请输入密码">
                    </div>
                    <div class="am-form-group">
                        <input type="text" class="tpl-form-input" id="verity_code" name="verity_code" style="width: 70%;float: left" placeholder="请输入验证码">
                        <img style="width: 30%;float: left;height: 32px;" id="img_code" onclick="this.setAttribute('src','{:url(\'login/verify\')}')" src="{:url('login/verify')}">
                    </div>
                    <div class="am-form-group">
                        <button type="button" class="am-btn am-btn-primary  am-btn-block tpl-btn-bg-color-success  tpl-login-btn">提交</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
    {include file="common:js" /}
<script src="https://cdn.bootcdn.net/ajax/libs/js-sha1/0.6.0/sha1.min.js"></script>
<script type="text/javascript">

    $(document).keydown(function(event){
        if(event.keyCode == 13){
            $('.am-btn').click();
        }
    });
    $('.am-btn').click(function () {
        if(document.getElementById('user-name').value ==''){
            layer.msg('请输入帐号!');
            return;
        }
        if(document.getElementById('user-password').value ==''){
            layer.msg('请输入密码!');
            return;
        }
        if(document.getElementById('verity_code').value ==''){
            layer.msg('请输入验证码!');
            return;
        }
        var data =  {username:document.getElementById('user-name').value,password:sha1(document.getElementById('user-password').value),verity_code:document.getElementById('verity_code').value};
        $.post('{:url("login")}',data,function (result) {
            if(result.code !=0){
                document.getElementById('img_code').setAttribute('src','{:url(\'login/verify\')}');
                layer.msg(result.msg);
            }else{
                if(result.data){
                    if(window.location.pathname !=result.data){
                        window.location.href =result.data;
                    }else{
                        window.location.href = '{:url(\'index/index\')}';
                    }
                }else{
                    window.location.href = '{:url(\'index/index\')}';
                }
            }
        },'json')
    })
</script>
</body>
</html>